﻿using ETA.Entity;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using ETA.IService;

namespace ETA.Web.Controllers
{
    public class FranchiseController : BaseController
    {

        private static IJoinApplyFormService _IJoinApplyFormService { set; get; }


        public FranchiseController(IJoinApplyFormService IJoinApplyFormService)
        {
            _IJoinApplyFormService = IJoinApplyFormService;
        }

        public ActionResult Index()
        {
            return Content("呵呵");
        }

        public ActionResult DomesticJoin()
        {
            return View(new JoinApplyForm());
        }


        public ActionResult SubmitDomesticJoin(JoinApplyForm model)
        {
            if (ModelState.IsValid)
            {
                var res = _IJoinApplyFormService.CreateJoinApplyForm(new CreateJoinApplyFormRequest
                {
                    JoinApplyForm = model
                });
                if (res.Result.IsSuccess)
                {
                    TempData["Info"] = "true";
                }
                else
                {
                    TempData["Info"] = res.Result.ErrMessage;
                }
            }
            else
            {
                TempData["Info"] = "模型验证有误";
            }
            return RedirectToAction("DomesticJoin");
        }


        public ActionResult JapanJoin()
        {
            return View(new JoinApplyForm());
        }


        [HttpPost]
        public ActionResult SummitJapanJoin(JoinApplyForm model)
        {
            if (ModelState.IsValid)
            {
                var res = _IJoinApplyFormService.CreateJoinApplyForm(new CreateJoinApplyFormRequest
                {
                    JoinApplyForm = model
                });
                if (res.Result.IsSuccess)
                {
                    TempData["Info"] = "true";
                }
                else
                {
                    TempData["Info"] = res.Result.ErrMessage;
                }
            }
            else
            {
                TempData["Info"] = "模型验证有误";
            }
            return RedirectToAction("JapanJoin");
        }

        public ActionResult DomesticJoinCenter()
        {
            return View();
        }

        public ActionResult JapanJoinCenter()
        {
            return View();
        }
    }
}
